home *** CD-ROM | disk | FTP | other *** search
/ Power Bytes: Money & Finance / PowerBytes Money and Finance CD-ROM 01 / PowerBytes Money and Finance CD-ROM 01.iso / Utilities / Scheduler Folder / Scheduler Source Code / Scheduler.bas < prev   
Encoding:
BASIC Source File  |  1986-07-10  |  11.6 KB  |  502 lines  |  [TEXT/EDIT]

  1. REM Generic Scheduling program 
  2. REM Written 5/7/86
  3. REM by Phil Jurgenson 
  4. REM Compu-Serve ID 71106,155
  5. REM GEnie Mail PJURGENSON
  6. REM absolutely free if you can use it!
  7. REM created with ZBASIC compiler by Zedcor, Inc.
  8. REM portions of the resulting object code
  9. REM are copyrighted (c) by Zedcor, Inc.
  10. DEF OPEN "DATAJURG"
  11. DEF MOUSE 1
  12. REM
  13. REM    dimension needed arrays
  14. REM
  15. DIM Boxtitle$(4)
  16. DIM Temp$(180)
  17. DIM Daynum(5)
  18. DIM Slot$(10,4)
  19. DIM Day$(5)
  20. DIM Timeslot$(36)
  21. DIM Hr$(10)
  22. DIM Mn$(4)
  23. DIM Dayslot$(5,36)
  24. DIM Month$(12)
  25. DIM Days(12)
  26. DIM Mo$(5)
  27. BREAK ON
  28. REM  get rid of the menus
  29. REM
  30. WINDOW OFF
  31. MENU 2,0,0,""
  32. MENU 3,0,0,""
  33. MENU 4,0,0,""
  34. MENU 5,0,0,""
  35. REM
  36. REM generic initialization - days of the week
  37. REM
  38. FOR Index = 1 TO 5
  39.     READ Day$(Index)
  40. NEXT Index
  41. DATA "Monday","Tuesday","Wednesday","Thursday","Friday"
  42. REM
  43. REM
  44. REM months to fill array
  45. REM
  46. FOR Index = 1 TO 12
  47.     READ Month$(Index),Days(Index)
  48. NEXT Index
  49. DATA "January",31,"February",28,"March",31,"April",30,"May",31,"June",30
  50. DATA "July",31,"August",31,"September",30,"October",31,"November",30
  51. DATA "December",31
  52. REM
  53. REM array for daily data
  54. REM
  55. Mn$(1) = ":00":Mn$(2) = ":15":Mn$(3) = ":30":Mn$(4) = ":45"
  56. FOR Index = 1 TO 5
  57.     Hr$(Index) = STR$(Index + 7)
  58. NEXT Index
  59. FOR Index = 6 TO 11
  60.     Hr$(Index) = STR$(Index - 5)
  61. NEXT Index
  62. REM set up the 36 daily times
  63. FOR Index = 1 TO 10
  64.     FOR Subindex = 1 TO 4
  65.         Slot$(Index,Subindex) = Hr$(Index) + Mn$(Subindex)
  66.     NEXT Subindex
  67. NEXT Index
  68. FOR Index = 1 TO 4
  69.     Timeslot$(Index) = Slot$(1,Index)
  70. NEXT Index
  71. FOR Index = 5 TO 8
  72.     Timeslot$(Index) = Slot$(2,Index - 4)
  73. NEXT Index
  74. FOR Index = 9 TO 12
  75.     Timeslot$(Index) = Slot$(3,Index - 8)
  76. NEXT Index
  77. FOR Index = 13 TO 16
  78.     Timeslot$(Index) = Slot$(4,Index - 12)
  79. NEXT Index
  80. FOR Index = 17 TO 20
  81.     Timeslot$(Index) = Slot$(5,Index - 16)
  82. NEXT Index
  83. FOR Index = 21 TO 24
  84.     Timeslot$(Index) = Slot$(6,Index - 20)
  85. NEXT Index
  86. FOR Index = 25 TO 28
  87.     Timeslot$(Index) = Slot$(7,Index - 24)
  88. NEXT Index
  89. FOR Index = 29 TO 32
  90.     Timeslot$(Index) = Slot$(8,Index - 28)
  91. NEXT Index
  92. FOR Index = 33 TO 36
  93.     Timeslot$(Index) = Slot$(9,Index - 32)
  94. NEXT Index
  95. REM
  96. REM turn off error trapping - do it in the program
  97. State = 1
  98. ON ERROR GOSUB 65535
  99. REM read existing data file, if present
  100. OPEN "I",1,"schedata"
  101. IF ERROR <> 0 GOSUB "schederr":GOTO "shutfile"
  102. INPUT #1,Mone$,Done$,Yone$,Mtwo$,Dtwo$,Ytwo$
  103. FOR Index = 1 TO 5
  104.     FOR Subindex = 1 TO 36
  105.         INPUT #1,Dayslot$(Index,Subindex)
  106.     NEXT Subindex
  107. NEXT Index
  108. "shutfile"
  109. CLOSE #1
  110. REM set coordinates to correspond with Macintosh pixel coords
  111. COORDINATE 511,341
  112. COORDINATE WINDOW
  113. REM display a copyright notice
  114. "copyright"
  115.     WINDOW 2,"",( 105, 80)-( 385, 260), 2
  116.     CALL MOVETO(100,20)
  117.     TEXT 0,12,4,1
  118.     PRINT "Scheduler"
  119.     TEXT 0,12,0,1
  120.     CALL MOVETO(80,40)
  121.     PRINT "by Phil Jurgenson"
  122.     CALL MOVETO(65,55)
  123.     TEXT 4,9,0,1
  124.     PRINT "(Compuserve - 71106,155)"
  125.     CALL MOVETO(80,70)
  126.     PRINT "(GEnie - PJURGENSON)"
  127.     CALL MOVETO(40,85)
  128.     PRINT "(Source code available on request)"
  129.     TEXT 0,12,0,1
  130.     CALL MOVETO(20,120)
  131.     PRINT "Created with Zedcor ZBASIC Compiler"
  132.     CALL MOVETO(65,140)
  133.     TEXT 4,9,0,1
  134.     PRINT "Portions of the code"
  135.     CALL MOVETO(45,155)
  136.     PRINT "copyright (c) 1985 by Zedcor, Inc."
  137.     MOUSE ON
  138. "mpoll"
  139.     Process = MOUSE(0)
  140.     IF Process = 0 THEN GOTO "mpoll"
  141.     MOUSE OFF
  142.     WINDOW CLOSE 2
  143. "intro"
  144.     REM get weekly dates, or display dates already in data file
  145.     WINDOW 1,"",( 105, 80)-( 385, 260), 2
  146.     CALL MOVETO(35, 20)
  147.     TEXT 0,12,0,1
  148.     PRINT "Please enter the week's dates:"
  149.     TEXT 3,12,0,1
  150.     CALL MOVETO(35, 50)
  151.     PRINT "Monday's"
  152.     CALL MOVETO(170, 50)
  153.     PRINT "Friday's"
  154.     CALL MOVETO(45, 65)
  155.     PRINT "Date"
  156.     CALL MOVETO(180, 65)
  157.     PRINT "Date"
  158.     CALL MOVETO(25,85)
  159.     PRINT "(MM/DD/YY)"
  160.     CALL MOVETO(165,85)
  161.     PRINT "(MM/DD/YY)"
  162.     EDIT FIELD  1,Mone$,( 10, 105)-( 35, 120), 3,3
  163.     CALL MOVETO(40,117)
  164.     PRINT "/"
  165.     EDIT FIELD 2,Done$,(55,105)-(75,120),3,3
  166.     CALL MOVETO(80,117)
  167.     PRINT "/"
  168.     EDIT FIELD 3,Yone$,(95,105)-(115,120),3,3
  169.     EDIT FIELD 4,Mtwo$,(145,105)-(165,120),3,3
  170.     CALL MOVETO(170,117)
  171.     PRINT "/"
  172.     EDIT FIELD 5,Dtwo$,(185,105)-(205,120),3,3
  173.     CALL MOVETO(210,117)
  174.     PRINT "/"
  175.     EDIT FIELD 6,Ytwo$,(225,105)-(245,120),3,3
  176.     BUTTON  1,1,"Okay",( 90, 145)-( 185, 165), 1
  177.     Numitem = 6
  178.     Item = 1
  179. "addintro"
  180.     DIALOG ON
  181.     EDIT FIELD Item
  182. "pollintro"
  183.     Process = DIALOG(0)
  184.     Buttonid = DIALOG(1)
  185.     IF Process = 0 THEN GOTO "pollintro"
  186.     IF Process = 1 THEN GOTO "getintro"
  187.     IF Process = 2 THEN GOSUB "newfield":GOTO "addintro"
  188.     IF (Process = 6) OR (Process = 7) THEN GOSUB "nextfield":GOTO "addintro"
  189.     GOTO "pollintro"
  190.     DIALOG OFF
  191. "getintro"
  192.     Mone$ = EDIT$(1)
  193.     Done$ = EDIT$(2)
  194.     Yone$ = EDIT$(3)
  195.     Mtwo$ = EDIT$(4)
  196.     Dtwo$ = EDIT$(5)
  197.     Ytwo$ = EDIT$(6)
  198.     REM decode user input, fill arrays with month names and dates for printout
  199.     Mo1num = VAL(Mone$)
  200.     Day1num = VAL(Done$)
  201.     Mo2num = VAL(Mtwo$)
  202.     Day2num = VAL(Dtwo$)
  203.     Week$ = Month$(Mo1num) + STR$(Day1num) + " -" + Month$(Mo2num) + STR$(Day2num)
  204.     Max = Days(Mo1num)
  205.     Indicator = Mo1num
  206.     Pointer = Day1num
  207.     FOR Index = 1 TO 5
  208.         LONG IF Pointer > Max
  209.             Pointer = 1
  210.             Indicator = Indicator + 1
  211.         END IF
  212.         Daynum(Index) = Pointer
  213.         Mo$(Index) = Month$(Indicator)
  214.         Boxtitle$(Index) = Day$(Index) + ", " + Mo$(Index) + STR$(Daynum(Index))
  215.         Pointer = Pointer + 1
  216.     NEXT Index
  217.     WINDOW CLOSE 1
  218. REM main function menu
  219. "main"
  220.     WINDOW 1,"",( 100, 35)-( 379, 312), 4
  221.     CALL MOVETO(85, 20)
  222.     TEXT 0,12,0,1
  223.     PRINT "Weekly Schedule"
  224.     BUTTON  1,1,"Monday",( 15, 45)-( 99, 62), 3
  225.     BUTTON  2,1,"Tuesday",( 15, 75)-( 100, 90), 3
  226.     BUTTON  3,1,"Wednesday",( 15, 105)-( 108, 121), 3
  227.     BUTTON  4,1,"Thursday",( 15, 135)-( 109, 152), 3
  228.     BUTTON  5,1,"Friday",( 15, 165)-( 100, 180), 3
  229.     BUTTON  6,State,"Clear Old Data",( 145, 45)-( 269, 62), 3
  230.     BUTTON  7,1,"Save Schedule",( 145, 75)-( 265, 90), 3
  231.     BUTTON 8,1,"Print Schedule",(145,105)-(265,120),3
  232.     BUTTON  9,1,"Quit",( 145, 135)-( 220, 150), 3
  233.     BUTTON  10,1,"Okay",( 100, 225)-( 184, 254), 1
  234.     Buttonid = 1
  235.     Oldbutton = 1
  236.     DIALOG ON
  237.     WHILE Buttonid <> 10
  238.         WHILE DIALOG(0) <> 1
  239.         WEND
  240.         Buttonid = DIALOG(1)
  241.         IF Buttonid > 0 AND Buttonid < 10 THEN GOSUB "getbutton"
  242.     WEND
  243.     DIALOG OFF
  244.     WINDOW CLOSE 1
  245.     ON Oldbutton GOSUB "monday","tuesday","wednesday","thursday","friday","empty","saveit","printsched","quit"
  246.     GOTO "main"
  247. REM indicate which button has been clicked
  248. "getbutton"
  249.     BUTTON Oldbutton,1
  250.     BUTTON Buttonid,2
  251.     Oldbutton = Buttonid
  252. RETURN
  253. REM move cursor to new edit field
  254. "newfield"
  255.     Item = DIALOG(2)
  256. RETURN
  257. REM move cursor to next consecutive edit field
  258. "nextfield"
  259.     Item = Item + 1
  260.     IF Item > Numitem THEN Item = Numitem
  261. RETURN
  262. REM clear out arrays for new data
  263. "empty"
  264.     FOR Index = 1 TO 5
  265.         FOR Subindex = 1 TO 36
  266.             Dayslot$(Index,Subindex) = ""
  267.         NEXT Subindex
  268.     NEXT Index
  269.     State = 0
  270. RETURN
  271. REM routines to display schedule screen for each day
  272. "monday"
  273.     Daynum = 1
  274.     GOSUB "schedscreen"
  275. RETURN
  276. "tuesday"
  277.     Daynum = 2
  278.     GOSUB "schedscreen"
  279. RETURN
  280. "wednesday"
  281.     Daynum = 3
  282.     GOSUB "schedscreen"
  283. RETURN
  284. "thursday"
  285.     Daynum = 4
  286.     GOSUB "schedscreen"
  287. RETURN
  288. "friday"
  289.     Daynum = 5
  290.     GOSUB "schedscreen"
  291. RETURN
  292. REM common screen to display time slots for each day
  293. "schedscreen"
  294.     WINDOW 2,"",( 0, 20)-( 511, 340), 3
  295.     CALL MOVETO(225, 9)
  296.     TEXT 4,9,0,1
  297.     PRINT Boxtitle$(Daynum)
  298.     Horiz = 5
  299.     Vert = 25
  300.     FOR Index = 1 TO 18
  301.         CALL MOVETO(Horiz,Vert)
  302.         PRINT Timeslot$(Index)
  303.         Vert = Vert + 16
  304.     NEXT Index
  305.     Horiz = 250
  306.     Vert = 25
  307.     FOR Index = 19 TO 36
  308.         CALL MOVETO(Horiz,Vert)
  309.         PRINT Timeslot$(Index)
  310.         Vert = Vert + 16
  311.     NEXT Index
  312.     Horiz = 50
  313.     Vert = 15
  314.     TEXT 4,9,0,1
  315.     FOR Index = 1 TO 18
  316.         EDIT FIELD Index,Dayslot$(Daynum,Index),(Horiz,Vert)-(Horiz+180,Vert+15),1
  317.         Vert = Vert + 16
  318.     NEXT Index
  319.     Horiz = 295
  320.     Vert = 15
  321.     FOR Index = 19 TO 36
  322.         EDIT FIELD Index,Dayslot$(Daynum,Index),(Horiz,Vert)-(Horiz+180,Vert+15),1
  323.         Vert = Vert + 16
  324.     NEXT Index
  325.     BUTTON  1,1,"Done",( 235, 302)-( 290, 318), 1
  326.     Numitem = 36
  327.     Item = 1
  328. "add"
  329.     DIALOG ON
  330.     EDIT FIELD Item
  331. "poll"
  332.     Process = DIALOG(0)
  333.     Buttonid = DIALOG(1)
  334.     IF Process = 0 THEN GOTO "poll"
  335.     IF Process = 1 THEN GOTO "getit"
  336.     IF Process = 2 THEN GOSUB "newfield":GOTO "add"
  337.     IF (Process = 6) OR (Process = 7) THEN GOSUB "nextfield":GOTO "add"
  338.     GOTO "poll"
  339.     DIALOG OFF
  340. REM fill schedule arrays with data entered into edit fields
  341. "getit"
  342.     FOR Index = 1 TO 36
  343.         Dayslot$(Daynum,Index) = EDIT$(Index)
  344.     NEXT Index
  345.     WINDOW CLOSE 2
  346. RETURN
  347. REM save schedule data to disk
  348. "saveit"
  349.     OPEN "O",1,"schedata"
  350.     PRINT #1,Mone$;",";Done$;",";Yone$;",";Mtwo$;",";Dtwo$;",";Ytwo$
  351.     FOR Index = 1 TO 5
  352.         FOR Subindex = 1 TO 36
  353.             PRINT #1,Dayslot$(Index,Subindex);",";
  354.         NEXT Subindex
  355.     NEXT Index
  356.     CLOSE #1
  357. RETURN
  358. REM print the schedule
  359. "printsched"
  360. REM make sure printer is ready
  361.     WINDOW 3,"",(140,115)-(335,220),2
  362.     BEEP
  363.     CALL MOVETO(5,15)
  364.     TEXT 1,12,0,1
  365.     PRINT "Make sure your printer is"
  366.     CALL MOVETO(5,35)
  367.     PRINT "set up . . . click the 'Okay'"
  368.     CALL MOVETO(5,55)
  369.     PRINT "button when you're ready."
  370.     BUTTON 1,1,"Okay",(53,77)-(119,98),1
  371.     DIALOG ON
  372.     WHILE DIALOG(0) <> 1
  373.     WEND
  374.     DIALOG OFF
  375.     WINDOW CLOSE 3
  376. REM put up message while printing
  377. "waitmessage"
  378.     WINDOW 3,"",( 110, 120)-( 387, 240), 2
  379.     CALL MOVETO(20, 30)
  380.     TEXT 0,12,0,1
  381.     PRINT "Go and get a cup of coffee or some-"
  382.     CALL MOVETO(20, 55)
  383.     PRINT "thing . . . This will probably take"
  384.     CALL MOVETO(20, 85)
  385.     PRINT "a little while . . ."
  386.     TEXT 1,12,0,1
  387.     REM loop to print 5 days
  388.     FOR Counter = 1 TO 5
  389. REM set up coordinates to use with printer
  390.         COORDINATE 630,455
  391.         ROUTE 128
  392.         TEXT 1,12,4,1
  393.         REM print weekly dates
  394.         PRINT Week$
  395.         REM draw the boxes in the print file
  396.         CALL MOVETO(0,35)
  397.         CALL LINETO(240,35)
  398.         CALL MOVETO(380,35)
  399.         CALL LINETO(630,35)
  400.         CALL MOVETO(0,35)
  401.         CALL LINETO(0,455)
  402.         CALL MOVETO(210,35)
  403.         CALL LINETO(210,455)
  404.         CALL MOVETO(420,35)
  405.         CALL LINETO(420,455)
  406.         CALL MOVETO(630,35)
  407.         CALL LINETO(630,455)
  408.         CALL MOVETO(0,245)
  409.         CALL LINETO(630,245)
  410.         CALL MOVETO(0,455)
  411.         CALL LINETO(630,455)
  412.         TEXT 4,9,0,1
  413.         CALL MOVETO(245,35)
  414.         PRINT Boxtitle$(Counter)
  415. REM print the schedule times
  416.         TEXT 4,9,4,1
  417.         Horiz = 5: Vert = 55
  418.         FOR Spotter = 1 TO 6
  419.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  420.             Vert = Vert + 30
  421.         NEXT Spotter
  422.         Horiz = 215: Vert = 55
  423.         FOR Spotter = 7 TO 12
  424.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  425.             Vert = Vert + 30
  426.         NEXT Spotter
  427.         Horiz = 425: Vert = 55
  428.         FOR Spotter = 13 TO 18
  429.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  430.             Vert = Vert + 30
  431.         NEXT Spotter
  432.         Horiz = 5: Vert = 265
  433.         FOR Spotter = 19 TO 24
  434.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  435.             Vert = Vert + 30
  436.         NEXT Spotter
  437.         Horiz = 215: Vert = 265
  438.         FOR Spotter = 25 TO 30
  439.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  440.             Vert = Vert + 30
  441.         NEXT Spotter
  442.         Horiz = 425: Vert = 265
  443.         FOR Spotter = 31 TO 36
  444.             CALL MOVETO(Horiz,Vert): PRINT Timeslot$(Spotter)
  445.             Vert = Vert + 30
  446.         NEXT Spotter
  447. REM print the schedule information for each day
  448.         TEXT 4,9,0,1
  449.         Horiz = 20: Vert = 70
  450.         FOR Index = 1 TO 6
  451.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  452.             Vert = Vert + 30
  453.         NEXT Index
  454.         Horiz = 230: Vert = 70
  455.         FOR Index = 7 TO 12
  456.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  457.             Vert = Vert + 30
  458.         NEXT Index
  459.         Horiz = 440: Vert = 70
  460.         FOR Index = 13 TO 18
  461.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  462.             Vert = Vert + 30
  463.         NEXT Index
  464.         Horiz = 20: Vert = 280
  465.         FOR Index = 19 TO 24
  466.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  467.             Vert = Vert + 30
  468.         NEXT Index
  469.         Horiz = 230: Vert = 280
  470.         FOR Index = 25 TO 30
  471.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  472.             Vert = Vert + 30
  473.         NEXT Index
  474.         Horiz = 440: Vert = 280
  475.         FOR Index = 31 TO 36
  476.             CALL MOVETO(Horiz,Vert): PRINT Dayslot$(Counter,Index)
  477.             Vert = Vert + 30
  478.         NEXT Index
  479.         CLEAR LPRINT
  480.         ROUTE 0
  481. REM this page is finished, do the next one
  482.     NEXT Counter
  483. REM return to screen display
  484.     COORDINATE 511,341
  485.     COORDINATE WINDOW
  486.     WINDOW CLOSE 3
  487. RETURN
  488. REM leave Scheduler
  489. "quit"
  490.     END
  491. REM error trap if no data file present
  492. "schederr"
  493.     Badresult = ERROR AND 255
  494.     IF Badresult = 3 THEN GOSUB "blankem" ELSE Mon$ = STR$(Badresult)
  495.     ERROR = 0
  496. RETURN
  497. "blankem"
  498.     State = 0
  499.     Mon$ = ""
  500.     Fri$ = ""
  501. RETURN
  502.